package net.hn.hnms.biz.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.hn.hnms.biz.project.domain.LegalPerson;
import net.hn.hnms.biz.project.domain.ProjectFile;
import net.hn.hnms.biz.project.vo.ProjectInfoVo;
import net.hn.hnms.biz.project.vo.SupplierInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface ProjectFileMapper extends BaseMapper<ProjectFile> {

    @Update("<script>" +
            " update  project_file set  del_flag = '1' " +
            " where project_id = #{projectId}" +
            "</script>")
    void updateDeleteById(@Param("projectId")String projectId);

    @Select("<script>" +
            " select project_file_id projectFileId,project_file_name projectFileName,project_file_path projectFilePath," +
            "create_user_id createUserId,create_time createTime,project_id projectId,oss_id ossId from project_file" +
            " where del_flag = '0' and project_id = #{projectId}" +
            "</script>")
    List<ProjectFile> selectFileById(@Param("projectId")String projectId);

    @Select("<script>" +
            " select project_id projectId,project_code projectCode,project_name projectName,construction_unit constructionUnit" +
            " from project_info " +
            " where del_flag = '0' " +
            "</script>")
    List<ProjectInfoVo> getProjectList();



    @Select("<script>" +
            " select project_id projectId,project_code projectCode,project_name projectName,construction_unit constructionUnit" +
            " from project_info " +
            " where del_flag = '0' and project_type = #{projectType} " +
            "</script>")
    List<ProjectInfoVo> getProjectListByType(@Param("projectType")String projectType);


    @Select("<script>" +
            " select project_id projectId,project_code projectCode,project_name projectName,construction_unit constructionUnit " +
            " from project_info " +
            " where del_flag = '0' " +
            "            <if test='projectId!= null and projectId != \"\" '>" +
            "                and project_id = #{projectId} " +
            "            </if>" +
            "            <if test='constructionUnit!= null and constructionUnit != \"\" '>" +
            " and construction_unit  like concat('%',#{constructionUnit},'%') " +
            "            </if>" +
            "</script>")
    List<ProjectInfoVo> getProjectListByCondition(@Param("projectId")String projectId,@Param("constructionUnit")String constructionUnit);
    @Select("<script>" +
            " select project_id projectId,project_code projectCode,project_name projectName,construction_unit constructionUnit " +
            " from project_info " +
            " where del_flag = '0' " +
            "            <if test='projectId!= null and projectId != \"\" '>" +
            "                and project_id = #{projectId} " +
            "            </if>" +
            "            <if test='projectName!= null and projectName != \"\" '>" +
            "                and project_name like concat('%',#{projectName},'%')  " +
            "            </if>" +
            "            <if test='constructionUnit!= null and constructionUnit != \"\" '>" +
            " and construction_unit  like concat('%',#{constructionUnit},'%') " +
            "            </if>" +
            "</script>")
    List<ProjectInfoVo> getProjectListByCondition_new(@Param("projectId")String projectId,@Param("projectName")String projectName,@Param("constructionUnit")String constructionUnit);

    @Select("<script>" +
            " select supplier_id supplierId,supplier_code supplierCode,supplier_name supplierName,legal_person_name legalPersonName" +
            " from supplier_info " +
            " where del_flag = '0' " +
            "</script>")
    List<SupplierInfoVo> getSupplierInfo();

    @Select("<script>" +
            " select legal_person_id legalPersonId,legal_person_code legalPersonCode,legal_person_name legalPersonName,company" +
            " from legal_person " +
            " where del_flag = '0' " +
            "</script>")
    List<LegalPerson> getLegalPerson();



}
